<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class arduino extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->view('index');
	}
        
        function reader(){
            
        }
        
        function sender(){
            
        }
        
        public function rc4($data){
            $key = 'ade';
            $i = 0;
            $j = 0;
            $S = '';
            $has = '';
            
            for($i=0;$i<256;$i++){
                $S[$i] = $i;
            }
            
            $j=0;
            for($i=0;$i<256;$i++){
                $j=($j+$S[$j]+$key[$i % strlen($key)]) % 256;
                $temp = $S[$i];
                $S[$i] = $S[$j];
                $S[$j] = $temp;
            }
            
            $i = $j = 0;
            for ($k=0;$k<strlen($data);$k++){
                 $i = ($i+1) % 256;
                 $j = ($j+$S[$i]) %256;
                 $temp = $S[$i];
                 $S[$i] = $S[$j];
                 $S[$j] = $temp;
                 $has[$k] = $data[$k]^$S[($S[$i]+$S[$j]) %256];
             }
            //$has[strlen($data)+1] = '\0';
            
            $var['data'] = implode($has);
            $this->load->view('index',$var);
            
        }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */